Skip to content

Add max_receivable_messages to topic subscribe#45

Merged
susrisha merged 1 commit intodevelopfrom
feature-stop-after-n-messages
Mar 5, 2026
Merged

Add max_receivable_messages to topic subscribe#45
susrisha merged 1 commit intodevelopfrom
feature-stop-after-n-messages

Conversation

@susrisha
Copy link
Collaborator

@susrisha susrisha commented Mar 5, 2026

Introduce an optional max_receivable_messages parameter to TopicAbstract.subscribe and implement support in AzureTopic and LocalTopic. AzureTopic now tracks per-receiver local_received_messages, limits receive batch sizes accordingly, and stops once the requested max is reached. Update example to use 'test-response', disable the random exception, fix task sleep to 5s, and lower concurrency to 1 with subscribe(..., max_receivable_messages=1). Bump package version to 0.0.24.

Testing done:

  • Invoked example.py with a test topic published 10 messages
  • Tested with Max concurrency 2 and Max messages 5 - Working as expected
  • Tested with max concurrency 5 and max messages 2 - Working as expected
  • Tested with max concurrency 2 and max messages 0 - Working as expected. Stays listening forever
  • Tested with max concurrency 2 and no input for max messages - working as expected. Listens forever

Caveat

  • This is not tested or implemented in local_topic.py. This does not work with Local provider

Introduce an optional max_receivable_messages parameter to TopicAbstract.subscribe and implement support in AzureTopic and LocalTopic. AzureTopic now tracks per-receiver local_received_messages, limits receive batch sizes accordingly, and stops once the requested max is reached. Update example to use 'test-response', disable the random exception, fix task sleep to 5s, and lower concurrency to 1 with subscribe(..., max_receivable_messages=1). Bump package version to 0.0.24.
@susrisha susrisha requested review from MashB and sujata-m March 5, 2026 05:40
@susrisha susrisha merged commit 779729a into develop Mar 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants